package net.csdn.business.discuss.api.model.query;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.csdn.business.discuss.common.dto.SuperPageQueryDTO;
import org.hibernate.validator.constraints.Range;
import org.springframework.util.StringUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;


/**
 * @ClassName DiscussQuery
 * @Description Discuss对象Query
 * @Author zhangyl
 * @Date 2023/7/18 11:02
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DiscussQuery extends SuperPageQueryDTO
{


    /** 组织ID/仓库ID */
    //@NotBlank(message = "sourceId不能为空")
    private String sourceId;
    /** 1:组织；2:仓库 */
    //@NotNull(message = "sourceType不能为空")
    @Range(min = 1, max = 2, message = "sourceType不合法")
    private Integer sourceType;

    /** serialNumber */
    private Integer serialNumber;

    /** 标题 */
    private String title;

    /** 是否锁定： 0-否; 1-是 */
    private Integer isLock;

    /** 是否被关闭： 0-否; 1-是 */
    private Integer isClosed;

    /** 是否采纳回答： 0-否; 1-是 */
    private Integer isAnswered;

    /** 是否置顶： 0-否; 1-是 */
    private Integer isPin;

    /** 是否在分类中置顶： 0-否; 1-是 */
    private Integer isCategoryPin;

    /** 审核状态 */
    private Integer auditStatus;

    /** 排序 */
    private Integer sort=0;

    /** 讨论所属分类id */
    private String categoryId;

    /** 讨论所属labelId */
    private String labelId;

    private String currUserId;

    public String generateKey() {
        StringBuilder stringBuilder=new StringBuilder();
        stringBuilder.append(this.serialNumber).append(":");
        stringBuilder.append(this.page).append(":");
        stringBuilder.append(this.size).append(":");
        stringBuilder.append(this.title).append(":");
        stringBuilder.append(this.sort).append(":");
        stringBuilder.append(this.categoryId).append(":");
        stringBuilder.append(this.labelId).append(":");
        stringBuilder.append(this.currUserId).append(":");
        stringBuilder.append(this.isLock).append(":");
        stringBuilder.append(this.isClosed).append(":");
        stringBuilder.append(this.isAnswered);
        return stringBuilder.toString();
    }
}
